# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Jens Pranaitis <jens@jenux.homelinux.org>

pkgname=busybox
pkgver=1.34.1
pkgrel=1
pkgdesc="Utilities for rescue and embedded systems"
arch=("loong64" "x86_64")
url="https://www.busybox.net"
license=('GPL')
makedepends=("ncurses" "musl" "kernel-headers-musl")
validpgpkeys=('C9E9416F76E610DBD09D040F47B70C55ACC9965B')
source=("$url/downloads/$pkgname-$pkgver.tar.bz2"{,.sig}
        "config")
sha256sums=('415fbd89e5344c96acf449d94a6f956dbed62e18e835fc83e064db33a34bd549'
            'SKIP'
            '82e934fbdf143028ffb19b195e34c2171dd3b2c17d1c5e37499068ade4d5b28f')
b2sums=('1f45f58db26ae0bae2eb728db3a7d49680d611f489c4633d1fdf2827d3c33285721e232f722ac1f80f2ad7616352df9fd6b8880bcb5fa0dc6787b70c897dd033'
        'SKIP'
        'ec7ab659d02bda59be7e0eaae532e5a3e1a53f630559fe66ddadadbdebe5baf31f9f9897e73a6a6f11aa9523158331eac74803035bf84ffab27d8941c181cc61')

build() {
  cd "$srcdir/$pkgname-$pkgver"

  cp "$srcdir"/config .config
  # reproducible build
  export KCONFIG_NOTIMESTAMP=1
  make CC=musl-gcc
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  install -Dm0755 busybox "$pkgdir"/usr/bin/busybox

  # docs
  install -Dm644 docs/busybox.1 "$pkgdir"/usr/share/man/man1/busybox.1
  for doc in BusyBox.html BusyBox.txt; do
    install -Dm644 docs/$doc "$pkgdir"/usr/share/doc/$pkgname/$doc
  done
}
